<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding:0;
            
        }

        .box{
            width:200px;
            text-align: center;
           margin:10px;
           box-shadow: 0px 0px 5px #ccc;
           padding: 10px;
        }
        ul{
            list-style: none;
        }



    </style>
    
</head>
<body>
    <div class="box">
        <h3>订单详情</h3>
        <ul>
            <li>手机 <span class="money">￥3000</span></li>
            <li>鼠标 <span class="money">￥100</span></li>
            <li>耳机 <span class="money">￥100</span></li>
        </ul>
        <div>
            <button class="pay">支付</button>
        </div>
    </div>

   <script>
       let pay_btn = document.getElementsByClassName('pay')[0]

       pay_btn.addEventListener('click',()=>{
          // 支付
          let money = document.getElementsByClassName('money')
        let buy = 0
        for (let index = 0; index < money.length; index++) {
            console.log(money[index].innerText)
            	
              // replace() 规定子字符串或要替换的模式的 RegExp 对象。
            buy += Number(money[index].innerText.replace(/[^0-9]/ig,""))
        }
        console.log(buy);

       if(confirm(`确定支付${buy}吗？`)){
        location.href=`./支付页-节流.html?puy=${buy}`
       
    }else{
        // 未支付

       }
      
    })
   </script>
</body>
</html>